package com.suxii.frpclient.utils;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.subjects.PublishSubject;

public class RxBus {
    private static final RxBus INSTANCE = new RxBus();
    private final PublishSubject<Object> subject = PublishSubject.create();

    public static RxBus getInstance() {
        return INSTANCE;
    }

    public void post(Object event) {
//        Log.e("aa","post"+event);
        subject.onNext(event);
    }

    public <T> Observable<T> toObservable(Class<T> eventType) {
        return subject.ofType(eventType);
    }
}